package com.predict.javademo.controller;

import com.predict.javademo.services.AutoEvaService;
import com.predict.javademo.services.DisplayDataService;
import com.predict.javademo.services.PredictApiService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.http.*;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Map;

@RestController
@CrossOrigin(origins = "*", allowedHeaders = "*", methods = {RequestMethod.GET, RequestMethod.POST, RequestMethod.OPTIONS})
@RequestMapping("/api")
@RequiredArgsConstructor
public class PredictApiController {

    private final PredictApiService predictApiService;
    private final DisplayDataService displayDataService;
    private final AutoEvaService autoEvaService;

    @PostMapping("/alg")
    public ResponseEntity<?> predict(HttpServletRequest request, HttpServletResponse response) throws IOException {
        return predictApiService.handle(request, response);
    }

    @PostMapping("/display")
    public ResponseEntity<?> displayData() {
        return displayDataService.displayData();
    }

    @PostMapping("/auto_eva")
    public ResponseEntity<?> autoEva(@RequestBody Map<String, Object> requestBody) {
        return autoEvaService.handleAutoEva(requestBody);
    }
    
//    // 添加别名路径，处理拼写错误的请求
//    @PostMapping("/aotu_eva")
//    public ResponseEntity<?> aotuEva(@RequestBody Map<String, Object> requestBody) {
//        return autoEvaService.handleAutoEva(requestBody);
//    }
}
